#ifndef GOBJECTS_H
#define GOBJECTS_H

#include <cyclone/cyclone.h>
#include "Vertex.h"
#include "Faces.h"
#include "Material.h"
#include "Texture.h"
#include "terrain.h"
#include "BoundingObjects.h"


#define FACE_ONLY 1
#define FACE_SLASH_NORMAL 2
#define FACE_TEXTURE_NORMAL 3
#define FACE_SLASH_SLASH_NORMAL 4

class GObjects : public BoundingObjects{
public:
	static vector<void *> allTheShips;
	static vector<void *> allTheIslands;
	static vector<void *> allTheCollectibles;
	static vector<Terrain *> allTheTerrains;
	
	static void addToAllTheShips(void *);
	static void addToAllTheIslands(void *);
	static void addToAllTheCollectibles(void *thisObject);
	//physics related
	cyclone::Vector3 position;
	cyclone::Quaternion orientation;
	cyclone::Vector3 extents;
	void setObjectPositionAndOrientation(float x,float y,float z,float angle);
	void setExtents(float xLength, float yLength, float zLength){
		extents.x = xLength;extents.y = yLength;extents.z = zLength;
	}
	static bool cannonBallImmediateExplosion;
	static bool physicsDebugInfo;
	//end of physics related

	float yRot;
	float scale,modelScale;
	string name;
	
	//this allows to mix models modeled in GL_CCW or GL_CW correctly, also culling will be done properly
	//only thing is set the modelsFrontFaceOrientation=GL_CCW/GL_CW appropriately
	int modelsFrontFaceOrientation;
	
	int nVertices,nFaces,nVectorNormals,nVectorTextures,nMaterials,nPoints;
	bool geometryModified;
	int displayListId;

	string gInputFolder;		//location of the .obj .mtl texture and map files
	vector<Vertex> vVector;		//vertex v
	vector<Faces>  fVector;		//face f
	vector<Vertex> vnVector;	//vertexNormal vn
	vector<Vertex> vtVector;    //vertexTexture vt
	vector<Vertex> pVector;		//point p
	vector<Material> mVector;   //materials m
	string materialFile;
	//made static... to reduce redundency...
	static vector<Texture> tVector;  //textures t
public:
	GObjects();
	GObjects(int, int, int, int);
	~GObjects(){}
	int loadGeometryObj(string objFileName,int nF=0.0f, int nV=0.0f, int nVN=0.0f, int nVT=0.0f);
	int drawGeometry();
	int drawGeometry(cyclone::RigidBody *thisObjectBody);

	int loadMaterial(string mFileName);
	int addTexturesToVector(string tFileName);

};

#endif